﻿﻿using System;
using System.Collections.Generic;
using System.Text;
namespace WebApplication1.DDD.Models.Entity.Common
{
    public class user:NFinal.Struct
    {
		public System.Int64 id;
		public System.Int64? group_id;
		public System.String user_name;
		public System.String salt;
		public System.String password;
		public System.String mobile;
		public System.String email;
		public System.String avatar;
		public System.String nick_name;
		public System.Int16? sex;
		public System.DateTime? birthday;
		public System.String telphone;
		public System.String area;
		public System.String address;
		public System.String qq;
		public System.String msn;
		public System.Decimal? amount;
		public System.Int64? point;
		public System.Int64? exp;
		public System.Int64? status;
		public System.DateTime? reg_time;
		public System.String reg_ip;
		#region 从get列表初始化实体类
		public static bool TryParse(NFinal.NameValueCollection get,out user par)
		{
			par=new user();
			try
			{
						System.Int64.TryParse(get["id"],out par.id);
						par.group_id=null;
						if(get["group_id"]!=null)
						{
							par.group_id=System.Int64.Parse(get["group_id"]);
						}
						par.user_name=get["user_name"];
						par.salt=get["salt"];
						par.password=get["password"];
						par.mobile=get["mobile"];
						par.email=get["email"];
						par.avatar=get["avatar"];
						par.nick_name=get["nick_name"];
						par.sex=null;
						if(get["sex"]!=null)
						{
							par.sex=System.Int16.Parse(get["sex"]);
						}
						par.birthday=null;
						if(get["birthday"]!=null)
						{
							par.birthday=System.DateTime.Parse(get["birthday"]);
						}
						par.telphone=get["telphone"];
						par.area=get["area"];
						par.address=get["address"];
						par.qq=get["qq"];
						par.msn=get["msn"];
						par.amount=null;
						if(get["amount"]!=null)
						{
							par.amount=System.Decimal.Parse(get["amount"]);
						}
						par.point=null;
						if(get["point"]!=null)
						{
							par.point=System.Int64.Parse(get["point"]);
						}
						par.exp=null;
						if(get["exp"]!=null)
						{
							par.exp=System.Int64.Parse(get["exp"]);
						}
						par.status=null;
						if(get["status"]!=null)
						{
							par.status=System.Int64.Parse(get["status"]);
						}
						par.reg_time=null;
						if(get["reg_time"]!=null)
						{
							par.reg_time=System.DateTime.Parse(get["reg_time"]);
						}
						par.reg_ip=get["reg_ip"];
			}
			catch
			{
				return false;
			}
			return true;
		}
		#endregion
		#region 写Json字符串
		public override void WriteJson(System.IO.TextWriter tw)
		{
			tw.Write("{");
					tw.Write("\"id\":");
					tw.Write(id.ToString());
					tw.Write(",");
					tw.Write("\"group_id\":");
					tw.Write(group_id==null?"null" : group_id.ToString());
					tw.Write(",");
					tw.Write("\"user_name\":");
					tw.Write("\"");
					tw.Write(user_name==null?"null":user_name);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"salt\":");
					tw.Write("\"");
					tw.Write(salt==null?"null":salt);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"password\":");
					tw.Write("\"");
					tw.Write(password==null?"null":password);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"mobile\":");
					tw.Write("\"");
					tw.Write(mobile==null?"null":mobile);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"email\":");
					tw.Write("\"");
					tw.Write(email==null?"null":email);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"avatar\":");
					tw.Write("\"");
					tw.Write(avatar==null?"null":avatar);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"nick_name\":");
					tw.Write("\"");
					tw.Write(nick_name==null?"null":nick_name);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"sex\":");
					tw.Write(sex==null?"null" : sex.ToString());
					tw.Write(",");
					tw.Write("\"birthday\":");
					tw.Write("\"");
					tw.Write(birthday==null?"null":birthday.ToString());
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"telphone\":");
					tw.Write("\"");
					tw.Write(telphone==null?"null":telphone);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"area\":");
					tw.Write("\"");
					tw.Write(area==null?"null":area);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"address\":");
					tw.Write("\"");
					tw.Write(address==null?"null":address);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"qq\":");
					tw.Write("\"");
					tw.Write(qq==null?"null":qq);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"msn\":");
					tw.Write("\"");
					tw.Write(msn==null?"null":msn);
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"amount\":");
					tw.Write(amount==null?"null" : amount.ToString());
					tw.Write(",");
					tw.Write("\"point\":");
					tw.Write(point==null?"null" : point.ToString());
					tw.Write(",");
					tw.Write("\"exp\":");
					tw.Write(exp==null?"null" : exp.ToString());
					tw.Write(",");
					tw.Write("\"status\":");
					tw.Write(status==null?"null" : status.ToString());
					tw.Write(",");
					tw.Write("\"reg_time\":");
					tw.Write("\"");
					tw.Write(reg_time==null?"null":reg_time.ToString());
					tw.Write("\"");
					tw.Write(",");
					tw.Write("\"reg_ip\":");
					tw.Write("\"");
					tw.Write(reg_ip==null?"null":reg_ip);
					tw.Write("\"");
			tw.Write("}");
		}
		#endregion
    }
}
